<?php
namespace app\api\model\v1;

/*
 * content : 用户权限生成类
 * Author  : Songyicong
 * time    : 2018-04-19 10:41:29
 * email   : m13726262373@163.com
 */

use app\api\model\BaseModel;
use think\Cache;

class UserAuth extends BaseModel{

    protected $table = "km_user_auth";

    /** 判断是否已经生成了openid */
    public static function isAuth($userId = ""){
        if(empty($userId)){
            return false;
        }
        $where['user_id'] = $userId;
        $results = self::where($where)->find();
        return empty($results)?false:$results->toArray();
    }

    /** 判断open_id是否存在 */
    public function isOpenId($openid = ""){
        if(empty($openid)){
            return null;
        }
        $auth_name = self::where('open_id',$openid)->find();
        return empty($auth_name)?$auth_name:$auth_name->toArray();
    }

}
